<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
  "http://www.w3.org/TR/html4/loose.dtd">
<html>
	
	<head>
		<title>Delft Language Exchange Project / Tandem Delft</title>  
		
		<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
		<link media="all" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/redmond/jquery-ui.css" rel="stylesheet">
		
		<script type="text/javascript" src="static/sha.js"></script>
		<script type="text/javascript" src="static/jquery.form.js"></script>
		<script type="text/javascript" src="static/jquery.blockUI.js"></script>
		<link rel="stylesheet" href="static/style.css" type="text/css" />
		<!--[if IE 7]>
			<script type="text/javascript" src="static/json2.js"></script>
			<link rel="stylesheet" type="text/css" href="static/style-ie7.css" />
		<![endif]-->
		<!--[if lte IE 6]>
			<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ie6countdown.com/">
		<![endif]-->
		
		<script type="text/javascript" src="static/jquery.prettyPhoto.js"></script>
		<link rel="stylesheet" type="text/css" href="static/jquery.prettyPhoto.css" media="screen" />
		
	</head>

	<body>
	
		<script type='text/javascript'><!--

		function create_send_message_overlay(id, title) {
			overlay = $('#'+id);
			form = $('#'+id+' form');
			textarea = $('#'+id+' textarea');
			overlay.dialog({
				modal: true,
				draggable: false,
				hide: 'fade',
				resizable: false,
				title: title,
				width: '50%',
				minWidth: '500px',
				buttons: { 
					"Send": function() { 
						// Check form manually (form.submit omits the onsubmit check) 
						if (form.get(0).onsubmit()) {
							overlay.parent().block({
								message: '<p>The message is being sent...<\/p>'
							}); 
							form.submit();
							textarea.val('');
						} 
					},
					"Cancel": function() { 
						overlay.dialog("close");
					}
				}
			});
			
            form.ajaxForm(function(response) {
				overlay.parent().block({
					message: '<p>'+response+'<\/p>'
				}); 
				setTimeout(function() {
	            	overlay.parent().unblock();
	            	overlay.dialog("close");
				}, 2000);
            }); 
		}

		$(document).ready(function(){
		    $("a[rel^='prettyPhoto']").prettyPhoto({
		    	social_tools: '',
		    	default_width: "80%",
		    	default_height: "90%",
			});
		});
        
		//--></script>	
	
		<?php if (count($view->messages) > 0) { ?>
		<div id="message-bar">
			<?php foreach ($view->messages as $message) { ?>
			<div class="message">
				<?php echo $message ?>
			</div>
			<?php } ?>
		</div>
		
		<?php /*
		<script type='text/javascript'>
			$('#message-bar').delay(15000).fadeTo(1000, 0.01);
		</script>
		*/ ?>
		
		<?php } ?>
		
		
		<?php
			require_once 'actions/static_page.cls.php';
			$static_page_action = new StaticPageAction();
			
			// TODO: pass in values of inputs in constructor
			$page_how = $static_page_action->get_direct_link();
			// TODO: this sets the value of the input in the action! Therefore, the different links are coupled while you expect them to be uncoupled.
			$page_how->set_value(StaticPageAction::INPUT_PAGE, StaticPageAction::PAGE_HOW_DOES_IT_WORK);
			$page_how = $page_how->__toString();
			
			$page_about = $static_page_action->get_direct_link();
			$page_about->set_value(StaticPageAction::INPUT_PAGE, StaticPageAction::PAGE_ABOUT);
			$page_about = $page_about->__toString();
			
			$page_contact = $static_page_action->get_direct_link();
			$page_contact->set_value(StaticPageAction::INPUT_PAGE, StaticPageAction::PAGE_CONTACT);
			$page_contact = $page_contact->__toString();
		?>
	
		<ul id="top-line" class='container'>
				
			<?php 
				if ($view->user != null) {
					$profile_action = new EditProfileAction();
					echo "<li><span class='vague'>logged in as</span> <a href='{$profile_action->get_direct_link()->__toString()}'>{$view->user->first_name}</a></li>";
					
					$logout_action = new LogoutAction();
					echo "<li><a href='{$logout_action->get_direct_link()->__toString()}'>log out</a></li>";
				}
			?>
			<li><a href="index.php">home</a></li>
			<?php 
				if ($view->user != null and $view->user->admin) {
					require_once 'actions/admin.cls.php';
					$admin = r(new AdminAction())->get_direct_link();
					echo "<li><a href='{$admin->__toString()}'>admin</a></li>";
				}
				
			?>
			<li><a href='<?php echo $page_contact; ?>'>contact</a></li>
			<li><a href='http://www.facebook.com/TandemLanguageDelft'><img src='static/img/facebook.png' class='icon' /></a></li>
			<li><a href='http://twitter.com/#!/search/%23tandemdelft'><img src='static/img/twitter.jpg' class='icon' /></a></li>
		</ul>
		
		<div id="header">
			<div id="light-blue-bar"></div>
			<div id="inner-header" class='container'>
				<div id="blue-bar"></div>
				<div id='title-header'>
					<div id="clouds"></div>
					<div id="title"></div>
				</div>
				<div id="people"></div>
			</div>
		</div>
		
		<div class="container" style="padding-bottom: 3em;">
			<div id="side-bar">
				<img id="logo" src="static/img/logo.jpg">
				<div id="facebook">
					<!--  START FACEBOOK CODE (Like Box) -->
					<iframe src="http://www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FTandemLanguageDelft&amp;width=280&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=true&amp;header=false&amp;height=350" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:280px; height:350px;" allowTransparency="true"></iframe> 
						 
					<!--  END FACEBOOK CODE -->
				</div>
			</div>
			<div id="body">

				<!-- <p style='text-align: center'>
					<b>Next meeting</b>: Tuesday the February 14, 19:30 till 21:00 at Caf&eacute; Doerak
				</p> -->
				
				<ul id="menu-list">
					<li id="menu-item-1" <?php echo $view->tab === 'home' ? 'class="active-menu-item"' : '';?> >
						<a href="index.php">home</a>
					</li> 
					<li id="menu-item-2" <?php echo $view->tab === StaticPageAction::PAGE_HOW_DOES_IT_WORK ? 'class="active-menu-item"' : '';?> >
						<a href="<?php echo $page_how; ?>">how does it work?</a>
					</li> 
					<li id="menu-item-3" <?php echo $view->tab === StaticPageAction::PAGE_ABOUT ? 'class="active-menu-item"' : '';?> >
						<a href="<?php echo $page_about; ?>">about the project</a>
					</li> 
					<li id="menu-item-4" <?php echo $view->tab === StaticPageAction::PAGE_CONTACT ? 'class="active-menu-item"' : '';?> >
						<a href="<?php echo $page_contact; ?>">contact organizers</a>
					</li> 
				</ul>
				<div id="content-wrapper">
					<div id="scratch-border-left"></div>
					<div id="scratch-border-right"></div>
					<div id="scratch-border-top"></div>
					<div id="content">
						
						<?php 
							require_once 'util.php';	
							if (ends_with($view->content, '.php')) {
								require $view->content;
							}
							else {
								echo $view->content;
							}
						?>
						
						<div style='clear:both'></div>
						
					</div>
					<div id="scratch-border-bottom"></div>
				</div>
			
				<?php if ($view->content != 'start.php') { ?>
				<div id="footer">
					<div id="logo-tudelft" class="org-logo">
						<a href="http://www.tudelft.nl">
							<img src="static/img/logo_TUDelft.png">
						</a>
					</div>
					<div id="logo-aegee" class="org-logo">
						<a href="http://www.aegee-delft.nl">
							<img src="static/img/logo_AEGEE.png">
						</a>
					</div>
					<div id="logo-diss" class="org-logo">
						<a href="http://www.diss-online.nl/">
							<img src="static/img/logo_DISS.png">
						</a>
					</div>
				</div>
				<?php } else { ?>
				<div id="footer" style="text-align: center; padding-top: 2em">
					
				</div>
				<?php } ?>
				
				<div id='feedback'>
					Feedback
				</div>
				<?php
					require_once 'actions/send_message.cls.php';
					$action = new SendMessageAction();
					$form = $action->get_form_link();
				?>		
				
				<div id='send-message' class='send-message' title='send message'>
					<p>
						Did you ran into a problem on this website or do you have a suggestion? We would like
						to hear from you! 
					</p>
					<?php 
						echo $form->start();
						echo $form->generate(new HiddenField(SendMessageAction::INPUT_DESTINATION, SendMessageAction::ADMIN));
						echo $form->generate(new TextAreaField(SendMessageAction::INPUT_MESSAGE));
						echo $form->end();
					?>
					<p>
						If you would like us to contact you,
						please include your contact details, since the message will be sent anonymously.
					</p>
				</div>
				
				<script type='text/javascript'><!--
				
				$('#feedback').click(function() {
					create_send_message_overlay("send-message", 'Feedback');
				});
		        
				//--></script>	
				
			</div>
			<div style="clear:both"></div>
		</div>
	</body>
	
</html>